package DataStructureAndAlgorithm.百度之星;

import java.util.Scanner;

public class AStart_1004 {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        int t = in.nextInt();
        long big,small;
        for (int i = 0; i < t; i++){
            long a = in.nextLong();
            long b = in.nextLong();
            big = Math.max(a,b);
            small = Math.min(a,b);
            long maxc = big - small;
            //如果两个数相等
            if (maxc == 0 && big != 1){
                long minc = getMinc(big);
                System.out.println(minc + " " + big);
            }else if (maxc == 1 || maxc == 0){
                System.out.println("-1 -1");
            }else {
                long minc = getMinc(maxc);
                System.out.println(minc + " " + maxc);
            }
        }
    }
    //用分解质因数的方法求最小c
    static long getMinc(long num){
        for (long i = 2; i * i <= num; i++){
            if (num % i == 0){
                return i;
            }
        }
        return num;
    }
}
